package hash

import (
	"fmt"
    "crypto/md5"
    "crypto/sha1"
    "io"
)

func Md5Encode(str string) string {
    data := []byte(str)
    has := md5.Sum(data)
    md5str := fmt.Sprintf("%x", has)
    return md5str
}

func Sha1Encode(str string) string {
    t := sha1.New();
	io.WriteString(t, str)
    sha1str := fmt.Sprintf("%x",t.Sum(nil))
    return sha1str
}
